struct ListNode* swapPairs(struct ListNode* head)
{
    if (head == NULL)
        return NULL;

    struct ListNode* newhead = head;

    struct ListNode* n1 = head;
    struct ListNode* n2 = NULL;
    struct ListNode* n3 = NULL;

    struct ListNode* prve = NULL;
    while (n1 && n1->next)
    {

        n2 = n1->next;
        n3 = n2->next;
        if (n1 == head)
        {
            n1->next = n2->next;
            n2->next = n1;
            newhead = n2;
        }
        else
        {
            n1->next = n2->next;
            n2->next = n1;

            prve->next = n2;
        }
        prve = n1;
        n1 = n3;
    }

    return newhead;
}